﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Developer.Entity;
using Super.Framework.Common;
using Super.Framework.Common.Reflection;
using Super.Framework.Redis;

namespace Developer.Service
{
    /// <summary>
    /// 基础服务
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseService<T> where T : class
    {
       
        #region 基础方法

        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity"></param>
        public static void Add(T entity)
        {
            SysInfo.DB.Set<T>().Add(entity);
            SysInfo.DB.SaveChanges();
        }

        /// <summary>
        /// 改变实体
        /// </summary>
        /// <param name="entity"></param>
        public static void Change(T entity)
        {
            SysInfo.DB.Entry(entity);
            SysInfo.DB.SaveChanges();
        }


        /// <summary>
        /// 泛型获取列表
        /// </summary>
        /// <returns></returns>
        public static DbSet<T> GetAll()
        {
            return SysInfo.DB.Set<T>();
        }

        #endregion


    }
}
